Trò chơi Tic-Tac-Toe, game đánh caro full source code
53.488 lượt xem;
- MaterialPerOwner.cs
- DemoChangeOwner /
- Demos /
- Photon Unity Networking /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4
5 [RequireComponent( typeof( PhotonView ) )]
6 public class MaterialPerOwner : Photon.MonoBehaviour
7 {
8 private int assignedColorForUserId;
9
10 Renderer m_Renderer;
11
12 void Start()
13 {
14 m_Renderer = GetComponent<Renderer>();
15 }
16
17 // Update is called once per frame
18 private void Update()
19 {
20 if( this.photonView.ownerId != assignedColorForUserId )
21 {
22 m_Renderer.material = PlayerVariables.GetMaterial( m_Renderer.material, this.photonView.ownerId );
23 this.assignedColorForUserId = this.photonView.ownerId;
24 //Debug.Log("Switched Material to: " + this.assignedColorForUserId + " " + this.renderer.material.GetInstanceID());
25 }
26 }
27 }
2 using System.Collections;
3
4
5 [RequireComponent( typeof( PhotonView ) )]
6 public class MaterialPerOwner : Photon.MonoBehaviour
7 {
8 private int assignedColorForUserId;
9
10 Renderer m_Renderer;
11
12 void Start()
13 {
14 m_Renderer = GetComponent<Renderer>();
15 }
16
17 // Update is called once per frame
18 private void Update()
19 {
20 if( this.photonView.ownerId != assignedColorForUserId )
21 {
22 m_Renderer.material = PlayerVariables.GetMaterial( m_Renderer.material, this.photonView.ownerId );
23 this.assignedColorForUserId = this.photonView.ownerId;
24 //Debug.Log("Switched Material to: " + this.assignedColorForUserId + " " + this.renderer.material.GetInstanceID());
25 }
26 }
27 }
Update is called once per frame
Debug.Log("Switched Material to: " + this.assignedColorForUserId + " " + this.renderer.material.GetInstanceID());